/**
 * COPYRIGHT HangZhou Trustway Technology Company Limited
 * All right reserved.
 */
package com.robam.cloud.authcenter.controller;

import com.robam.cloud.authcenter.service.FaceService;
import com.robam.cloud.common.bean.authcenter.dto.FaceParam;
import com.robam.cloud.common.bean.authcenter.entity.FaceRes;
import com.robam.cloud.common.bean.restful.entity.RespMsg;
import com.robam.cloud.log.annotation.OperationLogRecord;
import com.robam.cloud.restful.config.realcheck.annotation.CheckRealUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author 薛铁琪
 * @CreateTime 2020-07-26 15:59
 * @Version 1.0
 */
@Api("三方扫脸控制类")
@RestController
@RequestMapping("/face")
public class FaceController {
    @Autowired
    HttpServletRequest httpServletRequest;
    @Autowired
    FaceService faceService;

    @ApiOperation(
            value = "获取扫脸初始化信息（FaceUuid）-本人",
            notes = "获取扫脸初始化信息（FaceUuid）-本人")
    @OperationLogRecord(
            describe = "获取扫脸初始化信息（FaceUuid）-本人",
            modularCode = "face-getFaceInfo",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/getFaceInfo",
            method = RequestMethod.GET)
    @CheckRealUser
    public RespMsg<FaceParam> getFaceInfo() {
        return RespMsg.success(faceService.getFaceInfo(httpServletRequest));
    }


    @ApiOperation(
            value = "获取扫脸初始化信息（FaceUuid）-非本人",
            notes = "获取扫脸初始化信息（FaceUuid）-非本人")
    @OperationLogRecord(
            describe = "获取扫脸初始化信息（FaceUuid）-非本人",
            modularCode = "face-getOtherFaceInfo",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/getOtherFaceInfo",
            method = RequestMethod.GET)
    public RespMsg<FaceParam> getOtherFaceInfo(@RequestParam String certNo, @RequestParam String cerType, @RequestParam String certName) {
        return RespMsg.success(faceService.getOtherFaceInfo(httpServletRequest, certNo, cerType, certName));
    }


    @ApiOperation(
            value = "扫脸结果验证",
            notes = "扫脸结果验证")
    @RequestMapping(
            value = "/getFaceVerifyResult",
            method = RequestMethod.POST)
    @ApiImplicitParam(
            name = "faceRes",
            value = "对象",
            required = true,
            dataType = "FaceRes"
    )
    @OperationLogRecord(
            describe = "扫脸结果验证",
            modularCode = "face-getFaceVerifyResult",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    public RespMsg getFaceVerifyResult(@RequestBody FaceRes faceRes) {
        faceService.verifyFaceRsult(httpServletRequest, faceRes);
        return RespMsg.success();
    }
}
